#include <stdio.h>
char Map[20][20];
int W,H,MaxLenth;
int main()
{
    int i,j,x,y;
    void scan(int,int);
    for (;;)
    {
        MaxLenth=1;
        scanf("%d%d",&W,&H);
        if (W==0&&H==0)break;
        for (i=0;i<H;i++)
        {
            scanf("%s",Map[i]);
            for (j=0;j<W;j++)if (Map[i][j]=='@'){y=i;x=j;Map[i][j]='a';}
        }
        if (y!=0&&Map[y-1][x]=='.')
        {
            MaxLenth++;
            Map[y-1][x]='a';
            scan(y-1,x);
        }
        if (x!=0&&Map[y][x-1]=='.')
        {
            MaxLenth++;
            Map[y][x-1]='a';
            scan(y,x-1);
        }
        if (y!=H-1&&Map[y+1][x]=='.')
        {
            MaxLenth++;
            Map[y+1][x]='a';
            scan(y+1,x);
        }
        if (x!=W-1&&Map[y][x+1]=='.')
        {
            MaxLenth++;
            Map[y][x+1]='a';
            scan(y,x+1);
        }
        printf("%d\n",MaxLenth);
    }
    return 0;
}
void scan(int y,int x)
{
        if (y!=0&&Map[y-1][x]=='.')
        {
            MaxLenth++;
            Map[y-1][x]='a';
            scan(y-1,x);
        }
        if (x!=0&&Map[y][x-1]=='.')
        {
            MaxLenth++;
            Map[y][x-1]='a';
            scan(y,x-1);
        }
        if (y!=H-1&&Map[y+1][x]=='.')
        {
            MaxLenth++;
            Map[y+1][x]='a';
            scan(y+1,x);
        }
        if (x!=W-1&&Map[y][x+1]=='.')
        {
            MaxLenth++;
            Map[y][x+1]='a';
            scan(y,x+1);
        }
}

